const { body, param } = require("express-validator");
const validate = require("../middleware/validate");
const { Article } = require("../model");
const md5 = require("../util/md5");
const mongoose = require("mongoose");

exports.createArticle = validate([
  body("article.title").notEmpty().withMessage("文章标题不能为空"),
  body("article.content").notEmpty().withMessage("文章内容不能为空"),
  body("article.image").notEmpty().withMessage("文章图片不能为空"),
]);

exports.getArticle = validate([
  // param("articleId").custom(async (value) => {
  //   console.log(value,'--------value');
  //   if (!mongoose.isValidObjectId(value)) {
  //     return Promise.reject("文章ID类型错误");
  //   }
  // }),
]);
